package com.springboot.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.domain.Files;
import com.springboot.service.FilesServiceI;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.File;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HQJ
 * @since 2021-01-26
 */
@RestController
@RequestMapping("/fc")
public class FilesController {

    @Resource(name = "filesServiceI")
    private FilesServiceI fsi;

    @RequestMapping("/find")
    public List<Files> findFiles(Files files){

        QueryWrapper<Files> qw = new QueryWrapper<>();
        qw.eq("file_type","file");
        qw.select("id","parent_id","old_file_name","type_name","file_suffix");
        List<Files> list = fsi.list(qw);
        return list;
    }

    @RequestMapping("/findPage")
    public Page<Files> findPage(Files files, @Param(value = "pageNow") int pageNow){

        QueryWrapper<Files> qw = new QueryWrapper<>();
        qw.eq("file_type","file");
        qw.select("id","parent_id","old_file_name","type_name","file_suffix");
        Page<Files> page = new Page<>();
        page.setCurrent(pageNow==0?1:pageNow);
        fsi.page(page,qw);
        return page;
    }

}
/*
常用条件
1、通用条件
    a、比较(=,<>,>,<,>=,<=)
        eq(R column,Object val);
        ne(R column,Object val);
        gt(R column,Object val);
        lt(R column,Object val);
        ge(R column,Object val);
        le(R column,Object val);
    b、范围(between,not between,in,not in)
        between(R column,Object val1,Object val2);
        notBetween(R column,Object val1,Object val2);
        in(R column,Object... values)
        notIn(R column,Object... values)
        inSql(R column,Object... values) //例:inSql("id","select id from ssm_user")
    c、模糊(like)
        like(R column,Object val)// like '%内容%'
        notLike(R column,Object val)//not like '%内容%'
        likeRight(R column,Object val)// like '内容%'
        likeLeft(R column,Object val)// like '%内容'
    d、空值比较(isNull,isNotNull)
        isNull(R column,Object val)
        notIsNull(R column,Object val)
    e、分组、排序(group by,having,order by)
        groupBy(R...columns);//group by (name,sex,age)
        orderByAsc(R...columns)//order by name,sex asc 顺序排序
        orderByDesc(R...columns)//order by name,sex desc  倒序排序
2、查询列
    a、查询列(select)
        select(String...columns)//select id,name,sex from


 */
